package com.demostic.demostic_test.ui;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.view.MotionEvent;
import android.view.View;

import com.demostic.demostic_test.R;
import com.demostic.demostic_test.activity.MapEditActivity901;
import com.demostic.demostic_test.entity.ForbiddenInfo;
import com.demostic.demostic_test.entity.Point;
import com.demostic.demostic_test.entity.RoomKeyCoordinate;
import com.demostic.demostic_test.entity.RoomNameInfo;
import com.demostic.demostic_test.entity.VirTualInfo;
import com.demostic.demostic_test.utils.DataUtils;
import com.demostic.demostic_test.utils.DisplayUtil;
import com.demostic.demostic_test.utils.MyLog;
import com.demostic.demostic_test.utils.SettingUtils;
import com.demostic.demostic_test.utils.ToastUtils;
import com.glidebitmappool.GlideBitmapPool;
import com.loopj.android.http.AsyncHttpClient;

import org.greenrobot.eventbus.EventBus;
import org.java_websocket.drafts.Draft_75;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MapEditView901 extends View implements View.OnTouchListener {
    static final int ADJFBD = 10;
    static final int ADJVIR = 7;
    static final int DELFBD = 11;
    static final int DELVIR = 8;
    public static final int DRAG = 2;
    public static final int DRAWFBD = 5;
    public static final int DRAWVIR = 4;
    static final int DRGFBD = 9;
    static final int DRGVIR = 6;
    public static final int NONE = 1;
    static final int ROTFBD = 12;
    public static final String TAG = MapEditView901.class.getSimpleName();
    public static final int ZOOM = 3;
    public static int dis = 5;
    public static HashMap<Integer, Paint> drawHm;
    public static ArrayList<ForbiddenInfo> fbdInfoList;
    public static HashMap<Integer, Paint> hm;
    public static HashMap<Integer, Paint> hms;
    public static HashMap<Integer, RoomNameInfo> nameList;
    private static int picH;
    private static int picW;
    public static PointF rectMid;
    public static HashMap<Integer, Boolean> rmidHm;
    public static int virdis = 20;
    public static ArrayList<VirTualInfo> vtInfoList;
    public static ArrayList<ForbiddenInfo> whgInfoList;
    private final int MAPIDMAP = 1;
    private int MOPFBD = 1;
    private int OVAFBD = 0;
    private final int REAlMAP = 2;
    private int WHGFBD = 2;
    double adJInc;
    double adK;
    double adKInc;
    private Point adLeft;
    private Point adTop;
    private int[] adjvir_point;
    private Bitmap bitmap_mapid;
    private Bitmap bitmap_slam;
    private Point bottomP;
    private Bitmap bt;
    private Canvas canvas_mapid;
    private Canvas canvas_slam;
    private Point centerP;
    private Rect chRect;
    private Path chargePH;
    private Bitmap chb_bitmap;
    private int chgHeight;
    private int chgWidth;
    private Context context;
    PointF curMoveP;
    private float curScale = 1.0f;
    private Paint cvPaint;
    private Bitmap del_bitmap;
    private float distance;
    private Paint drBitPaint;
    private int[] drgvir_point;
    private float drgx;
    private float drgy;
    private float dx;
    private float dy;
    private float end_x;
    private float end_y;
    private ForbiddenInfo fbdInfo;
    private final int fbdMaxSize = 10;
    private Path fbdPath;
    private int[] fbdPoint;
    private Rect fbdRect;
    private Region fbdRegion;
    private int fbdType;
    private Rect fbpRect;
    private Rect fbrRect;
    private boolean firstRemove;
    private Paint.FontMetrics fontMetrics;
    private int height;
    private Path hostPH;
    private RoomKeyCoordinate info;
    private boolean isRemoved;
    private Path jugPath;
    private int[] keyP;
    private Point leftP;
    private Point mBottom;
    private Canvas mCanvas;
    private Point mLeft;
    private Point mRight;
    private Point mTop;
    private byte[] mapidBytes;
    private Matrix matrix = new Matrix();
    private Matrix matrixs = new Matrix();
    private float maxScale = 10.0f;
    private PointF mcenterP;
    private Point mchargeP;
    private Point mhostP;
    PointF midPoint;
    private float minScale = 0.1f;
    private int[] mn;
    int mode = 0;
    private float move_x;
    private float move_y;
    private double mvbtmx;
    private double mvbtmy;
    private Rect mvdRect;
    private Rect mvpRect;
    private Rect mvrRect;
    private double mvtopx;
    private double mvtopy;
    private int[] newVirP = new int[4];
    private boolean oneContains;
    private float orgScale = 1.0f;
    float oriDis = 1.0f;
    private Paint paint_1;
    private Paint paint_2;
    private Paint paint_mopfbd;
    private Paint paint_ovafbd;
    private Paint paint_position;
    private Paint paint_slam;
    private Paint paint_stroke;
    private Paint paint_virtual;
    private Paint paint_whgfbd;
    PointF preMoveP;
    private Paint pt_oval;
    private Paint pt_text;
    private Bitmap pul_bitmap;
    private int remove_fbdindex;
    private int remove_virindex;
    private Point rightP;
    private Point rotBottom;
    PointF rotCenterP;
    private Point rotLeft;
    private Point rotRight;
    private Point rotTop;
    private Bitmap rot_bitmap;
    private byte[] slamBytes;
    private Rect srcRect;
    PointF startPoint;
    private float start_x;
    private float start_y;
    private Rect textRect;
    private Point topP;
    private int trsx;
    private int trsy;
    private RectF tvRectF;
    private boolean twoContains;
    float[] values = new float[9];
    private final int virMaxSize = 10;
    private int[] virPoint;
    private final int whgMaxSize = 1;
    private int width;
    int x = 0;
    int y = 0;

    public MapEditView901(Context context2) {
        super(context2);
        this.context = context2;
        init();
        initPaint();
        setOnTouchListener(this);
    }

    private void init() {
        this.info = new RoomKeyCoordinate();
        this.jugPath = new Path();
        this.fbdPath = new Path();
        this.hostPH = new Path();
        this.chargePH = new Path();
        rectMid = new PointF();
        this.tvRectF = new RectF();
        this.startPoint = new PointF();
        this.rotCenterP = new PointF();
        this.preMoveP = new PointF();
        this.curMoveP = new PointF();
        this.mLeft = new Point();
        this.mTop = new Point();
        this.mRight = new Point();
        this.mBottom = new Point();
        this.adLeft = new Point();
        this.adTop = new Point();
        this.centerP = new Point();
        this.leftP = new Point();
        this.topP = new Point();
        this.rightP = new Point();
        this.bottomP = new Point();
        this.mvpRect = new Rect();
        this.mvdRect = new Rect();
        this.mvrRect = new Rect();
        this.mcenterP = new PointF();
        this.mchargeP = new Point();
        this.mhostP = new Point();
        this.fbdRegion = new Region();
        vtInfoList = new ArrayList<>();
        whgInfoList = new ArrayList<>();
        fbdInfoList = new ArrayList<>();
        rmidHm = new HashMap<>();
        nameList = new HashMap<>();
        this.bitmap_slam = GlideBitmapPool.getBitmap(AsyncHttpClient.DEFAULT_RETRY_SLEEP_TIME_MILLIS, AsyncHttpClient.DEFAULT_RETRY_SLEEP_TIME_MILLIS, Bitmap.Config.ARGB_8888);
        this.canvas_slam = new Canvas(this.bitmap_slam);
        this.bitmap_mapid = GlideBitmapPool.getBitmap(AsyncHttpClient.DEFAULT_RETRY_SLEEP_TIME_MILLIS, AsyncHttpClient.DEFAULT_RETRY_SLEEP_TIME_MILLIS, Bitmap.Config.ARGB_8888);
        this.canvas_mapid = new Canvas(this.bitmap_mapid);
        this.chb_bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.charge_base);
        this.del_bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.delete);
        this.pul_bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.adjust);
        this.rot_bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.rotate);
        this.srcRect = new Rect(0, 0, this.del_bitmap.getWidth(), this.del_bitmap.getHeight());
        this.chRect = new Rect(0, 0, this.chb_bitmap.getWidth(), this.chb_bitmap.getHeight());
    }

    private void initPaint() {
        this.cvPaint = DisplayUtil.getMapPaint(getResources().getColor(R.color.paint_f2));
        this.paint_position = DisplayUtil.getHostPaint(getResources().getColor(R.color.position_color));
        this.paint_virtual = DisplayUtil.getRoadPaint(getResources().getColor(R.color.color_vir));
        this.paint_virtual.setStrokeWidth(1.0f);
        this.paint_ovafbd = DisplayUtil.getFbdPaint();
        this.paint_mopfbd = DisplayUtil.getFbdPaints();
        this.paint_whgfbd = DisplayUtil.getWhgPaint();
        this.paint_slam = new Paint();
        this.paint_stroke = DisplayUtil.getRoadPaint(getResources().getColor(R.color.color_vir));
        this.paint_stroke.setStrokeWidth(1.0f);
        this.paint_1 = DisplayUtil.getMapPaint(getResources().getColor(R.color.obstacles_color));
        this.paint_2 = DisplayUtil.getMapPaint(getResources().getColor(R.color.notclean_color));
        this.drBitPaint = new Paint();
        this.drBitPaint.setFilterBitmap(false);
        this.drBitPaint.setAntiAlias(false);
        drawHm = DisplayUtil.getdrPainthm(this.context);
        hm = DisplayUtil.getdrPainthm(this.context);
        hms = DisplayUtil.getPainthms(this.context);
        this.pt_oval = DisplayUtil.getMapPaint(getResources().getColor(R.color.pa_oval));
        this.pt_oval.setStyle(Paint.Style.FILL);
        this.pt_oval.setAntiAlias(true);
        this.pt_text = DisplayUtil.getMapPaint(-1);
        this.pt_text.setTextSize(10.0f);
        this.pt_text.setAntiAlias(true);
        this.pt_text.setTextAlign(Paint.Align.CENTER);
        this.fontMetrics = this.pt_text.getFontMetrics();
        this.distance = ((this.fontMetrics.bottom - this.fontMetrics.top) / 2.0f) - this.fontMetrics.bottom;
        this.textRect = new Rect();
    }

    private void setpicMatrixs(float curScale2) {
        virdis = 20;
        float sx = 1.0f / curScale2;
        if (sx > 0.3f) {
            sx = 0.3f;
        }
        if (sx < 0.1f) {
            sx = 0.1f;
        }
        this.matrixs.reset();
        this.matrixs.postScale(sx, sx);
        virdis = (int) (((float) virdis) / curScale2);
        virdis = virdis > 20 ? 20 : virdis;
        virdis = virdis < 10 ? 10 : virdis;
        Bitmap numBt = Bitmap.createBitmap(this.del_bitmap, 0, 0, this.del_bitmap.getWidth(), this.del_bitmap.getHeight(), this.matrixs, true);
        picW = numBt.getWidth();
        picH = numBt.getHeight();
        MyLog.e(TAG, "setpicMatrixs===:" + curScale2 + "," + sx + "<->" + picW + "," + picH + "<->" + virdis);
        this.bt = Bitmap.createBitmap(this.chb_bitmap, 0, 0, this.chb_bitmap.getWidth(), this.chb_bitmap.getHeight(), this.matrixs, true);
        this.chgWidth = this.bt.getWidth();
        this.chgHeight = this.bt.getHeight();
    }

    /* access modifiers changed from: protected */
    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        this.mCanvas = canvas;
        if (this.width == 0 || this.height == 0) {
            this.width = getMeasuredWidth();
            this.height = getMeasuredHeight();
        }
        canvas.drawColor(0, PorterDuff.Mode.CLEAR);
        if (this.mode != 2 && this.mode != 3 && !MapEditActivity901.isVirEdit && !MapEditActivity901.isMopFbdEdit && !MapEditActivity901.isOvaFbdEdit && !MapEditActivity901.isWhgEdit) {
            this.canvas_slam.drawColor(0, PorterDuff.Mode.CLEAR);
            this.canvas_mapid.drawColor(0, PorterDuff.Mode.CLEAR);
        }
        canvas.drawPaint(this.cvPaint);
        this.matrix.reset();
        this.matrix.postTranslate((((float) (this.width / 2)) - this.mcenterP.x) + this.drgx, (((float) (this.height / 2)) - this.mcenterP.y) + this.drgy);
        this.matrix.postScale(this.curScale, this.curScale, (float) (this.width / 2), (float) (this.height / 2));
        MyLog.e(TAG, "test crash on Draw:" + this.width + "," + this.height + "," + this.curScale + "," + this.mcenterP.x + "," + this.mcenterP.y);
        canvas.concat(this.matrix);
        setpicMatrixs(this.curScale);
        drawMap();
        if (nameList != null && nameList.size() > 0) {
            for (Map.Entry<Integer, RoomNameInfo> entry : nameList.entrySet()) {
                RoomNameInfo info2 = entry.getValue();
                String roomname = info2.getRoomname();
                if (!roomname.equals("")) {
                    int[] namecoord = info2.getNamecoordinate();
                    int x2 = namecoord[0];
                    int y2 = 1500 - namecoord[1];
                    this.pt_text.getTextBounds(roomname, 0, roomname.length(), this.textRect);
                    this.tvRectF.left = (float) ((x2 - (this.textRect.width() / 2)) - 5);
                    this.tvRectF.top = (float) ((y2 - (this.textRect.height() / 2)) - 5);
                    this.tvRectF.right = (float) ((this.textRect.width() / 2) + x2 + 5);
                    this.tvRectF.bottom = (float) ((this.textRect.height() / 2) + y2 + 5);
                    float baseline = this.tvRectF.centerY() + this.distance;
                    canvas.drawRoundRect(this.tvRectF, 50.0f, 50.0f, this.pt_oval);
                    canvas.drawText(roomname, this.tvRectF.centerX(), baseline, this.pt_text);
                }
            }
        }
        if (!MapEditActivity901.isUnifyMove) {
            doEditMoveOpearate();
        }
        if (vtInfoList.size() > 0) {
            int size = vtInfoList.size();
            for (int i = 0; i < size; i++) {
                VirTualInfo info3 = vtInfoList.get(i);
                int[] virData = info3.getVirData();
                canvas.drawLine((float) virData[0], (float) virData[1], (float) virData[2], (float) virData[3], this.paint_virtual);
                if ((MapEditActivity901.isVirEdit || MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit) && info3.isNewAdd()) {
                    drawVirSmallPic(virData[0], virData[1], virData[2], virData[3]);
                    if (this.mode == 1) {
                        info3.setNewAdd(false);
                    }
                }
            }
        }
        if (fbdInfoList.size() > 0) {
            int fbsize = fbdInfoList.size();
            for (int i2 = 0; i2 < fbsize; i2++) {
                ForbiddenInfo info4 = fbdInfoList.get(i2);
                int[] fbdData = info4.getFbdData();
                drawUnifyFbdPath(fbdData[0], fbdData[1], fbdData[2], fbdData[3], fbdData[4], fbdData[5], fbdData[6], fbdData[7], info4.getFbdType());
                if ((MapEditActivity901.isVirEdit || MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit) && info4.isNewAdd()) {
                    drawFbdSmallPic(fbdData[0], fbdData[1], fbdData[4], fbdData[5], fbdData[6], fbdData[7]);
                    if (this.mode == 1) {
                        info4.setNewAdd(false);
                    }
                }
            }
        }
        if (whgInfoList.size() > 0) {
            int fbsize2 = whgInfoList.size();
            for (int i3 = 0; i3 < fbsize2; i3++) {
                ForbiddenInfo info5 = whgInfoList.get(i3);
                int[] fbdData2 = info5.getFbdData();
                drawUnifyFbdPath(fbdData2[0], fbdData2[1], fbdData2[2], fbdData2[3], fbdData2[4], fbdData2[5], fbdData2[6], fbdData2[7], info5.getFbdType());
                if (MapEditActivity901.isWhgEdit && info5.isNewAdd()) {
                    drawFbdSmallPic(fbdData2[0], fbdData2[1], fbdData2[4], fbdData2[5], fbdData2[6], fbdData2[7]);
                    if (this.mode == 1) {
                        info5.setNewAdd(false);
                    }
                }
            }
        }
    }

    private void drawMap() {
        if (this.mode != 2 && this.mode != 3 && !MapEditActivity901.isVirEdit && !MapEditActivity901.isMopFbdEdit && !MapEditActivity901.isOvaFbdEdit && !MapEditActivity901.isWhgEdit) {
            drawMapByBytes(this.slamBytes, this.bitmap_slam, this.canvas_slam, 2);
            drawMapByBytes(this.mapidBytes, this.bitmap_mapid, this.canvas_mapid, 1);
        }
        this.mCanvas.drawBitmap(this.bitmap_mapid, 0.0f, 0.0f, this.drBitPaint);
        this.mCanvas.drawBitmap(this.bitmap_slam, 0.0f, 0.0f, this.drBitPaint);
        if (!(this.mchargeP.x == 0 || this.mchargeP.y == 0)) {
            this.mCanvas.drawBitmap(this.chb_bitmap, this.chRect, getDstRects(this.mchargeP.x, this.mchargeP.y), (Paint) null);
        }
        if (this.mhostP.x != 0 && this.mhostP.y != 0) {
            this.mCanvas.drawCircle((float) this.mhostP.x, (float) this.mhostP.y, 15.0f / this.curScale, this.paint_position);
        }
    }

    private void drawMapByBytes(byte[] bytes, Bitmap bitmap, Canvas canvas, int type) {
        if (bytes != null) {
            int btlength = bytes.length;
            for (int i = 0; i < btlength; i += 3) {
                int attr = bytes[i] & Draft_75.END_OF_FRAME;
                int length = DataUtils.bytesToUInt(new byte[]{bytes[i + 1], bytes[i + 2]}, 0);
                if (attr == 1) {
                    this.paint_slam = this.paint_1;
                } else if (attr == 2 || attr == 11) {
                    this.paint_slam = drawHm.get(1);
                } else if (attr > 11) {
                    this.paint_slam = drawHm.get(Integer.valueOf(attr - 10));
                }
                if (type == 1) {
                    saveRoomID(attr);
                }
                for (int j = 0; j < length; j++) {
                    if (this.x >= 1500) {
                        this.x = 0;
                        this.y++;
                    }
                    if (attr != 3) {
                        canvas.drawPoint((float) this.x, (float) (1500 - this.y), this.paint_slam);
                        canvas.save();
                    }
                    this.x++;
                }
            }
            this.x = 0;
            this.y = 0;
        }
        this.mCanvas.drawBitmap(bitmap, 0.0f, 0.0f, this.paint_1);
    }

    private void saveRoomID(int attr) {
        if (MapEditActivity901.isPatEdit && attr != 1 && attr != 3) {
            if (attr == 2 || attr == 11) {
                if (rmidHm.containsKey(Integer.valueOf(attr))) {
                    return;
                }
                if (attr != 2 || !rmidHm.containsKey(11)) {
                    rmidHm.put(Integer.valueOf(attr), false);
                    return;
                }
                rmidHm.remove(11);
                rmidHm.put(2, false);
            } else if (!rmidHm.containsKey(Integer.valueOf(attr))) {
                rmidHm.put(Integer.valueOf(attr), false);
            }
        }
    }

    private void doEditMoveOpearate() {
        if (MapEditActivity901.isVirEdit || MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit || MapEditActivity901.isWhgEdit) {
            onDrawUnifyVirFbd();
        }
    }

    private void onDrawUnifyVirFbd() {
        switch (this.mode) {
            case 6:
                this.mCanvas.drawLine((float) this.newVirP[0], (float) this.newVirP[1], (float) this.newVirP[2], (float) this.newVirP[3], this.paint_virtual);
                drawVirSmallPic(this.newVirP[0], this.newVirP[1], this.newVirP[2], this.newVirP[3]);
                return;
            case 7:
                this.mCanvas.drawLine((float) this.adjvir_point[0], (float) this.adjvir_point[1], (float) ((int) this.move_x), (float) ((int) this.move_y), this.paint_virtual);
                drawVirSmallPic(this.adjvir_point[0], this.adjvir_point[1], (int) this.move_x, (int) this.move_y);
                return;
            case 8:
            case 11:
            default:
                if (MapEditActivity901.isVirEdit) {
                    if (this.mode == 4) {
                        this.mCanvas.drawLine(this.start_x, this.start_y, this.move_x, this.move_y, this.paint_virtual);
                        return;
                    }
                    return;
                } else if ((MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit || MapEditActivity901.isWhgEdit) && this.mode == 5) {
                    drawUnifyFbdPath((int) this.start_x, (int) this.start_y, (int) this.start_x, (int) this.move_y, (int) this.move_x, (int) this.move_y, (int) this.move_x, (int) this.start_y, this.fbdInfo.getFbdType());
                    return;
                } else {
                    return;
                }
            case 9:
                drawUnifyFbdPath(this.trsx + this.mLeft.x, this.trsy + this.mLeft.y, this.trsx + this.mTop.x, this.trsy + this.mTop.y, this.trsx + this.mRight.x, this.trsy + this.mRight.y, this.trsx + this.mBottom.x, this.trsy + this.mBottom.y, this.fbdType);
                drawFbdSmallPic(this.mvdRect.centerX(), this.mvdRect.centerY(), this.mvpRect.centerX(), this.mvpRect.centerY(), this.mvrRect.centerX(), this.mvrRect.centerY());
                return;
            case 10:
                if (this.adK == 0.0d) {
                    drawUnifyFbdPath(this.adLeft.x, this.adLeft.y, this.adLeft.x, (int) this.move_y, (int) this.move_x, (int) this.move_y, (int) this.move_x, this.adLeft.y, this.fbdType);
                    drawFbdSmallPic(this.adLeft.x, this.adLeft.y, (int) this.move_x, (int) this.move_y, (int) this.move_x, this.adLeft.y);
                    return;
                }
                drawUnifyFbdPath(this.adLeft.x, this.adLeft.y, (int) this.mvtopx, (int) this.mvtopy, (int) this.move_x, (int) this.move_y, (int) this.mvbtmx, (int) this.mvbtmy, this.fbdType);
                drawFbdSmallPic(this.adLeft.x, this.adLeft.y, (int) this.move_x, (int) this.move_y, (int) this.mvbtmx, (int) this.mvbtmy);
                return;
            case 12:
                drawUnifyFbdPath(this.rotLeft.x, this.rotLeft.y, this.rotTop.x, this.rotTop.y, this.rotRight.x, this.rotRight.y, this.rotBottom.x, this.rotBottom.y, this.fbdType);
                drawFbdSmallPic(this.rotLeft.x, this.rotLeft.y, this.rotRight.x, this.rotRight.y, this.rotBottom.x, this.rotBottom.y);
                return;
        }
    }

    @Override // android.view.View.OnTouchListener
    public boolean onTouch(View view, MotionEvent event) {
        switch (event.getAction() & 255) {
            case 0:
                if (!MapEditActivity901.isUnifyMove) {
                    doVirtualActionDownOperate(event);
                    break;
                } else {
                    initDraging(event);
                    break;
                }
            case 1:
                if (!MapEditActivity901.isUnifyMove) {
                    doVirtualActionUpOperate(event);
                }
                invalidate();
                this.oneContains = false;
                this.twoContains = false;
                this.dx = this.drgx;
                this.dy = this.drgy;
                this.mode = 1;
                break;
            case 2:
                if (!MapEditActivity901.isUnifyMove) {
                    doVirtualActionMoveOperate(event);
                    break;
                } else {
                    doDragOrZoom(event);
                    break;
                }
            case 5:
                initZooming(event);
                this.twoContains = true;
                break;
            case 6:
                this.orgScale = this.curScale;
                break;
        }
        return true;
    }

    private void doVirtualActionDownOperate(MotionEvent event) {
        this.matrix.getValues(this.values);
        PointF virDown = getMatrixValues(event, 1);
        this.start_x = virDown.x;
        this.start_y = virDown.y;
        MyLog.e(TAG, "action down===:" + this.start_x + "," + this.start_y + "<-->" + event.getX() + "," + event.getY() + "<->" + MapEditActivity901.isUnifyMove);
        doDownOperate(event);
    }

    private void doDownOperate(MotionEvent event) {
        boolean z = true;
        if (MapEditActivity901.isVirEdit) {
            if (vtInfoList.size() != 0 || fbdInfoList.size() != 0) {
                if (!traverseVirList((int) this.start_x, (int) this.start_y) && !traverseFbdList(fbdInfoList, (int) this.start_x, (int) this.start_y)) {
                    z = false;
                }
                this.oneContains = z;
                this.firstRemove = this.oneContains;
                if (this.oneContains && (this.mode == 8 || this.mode == 6)) {
                    vtInfoList.remove(this.remove_virindex);
                }
                if (this.oneContains && (this.mode == 11 || this.mode == 9)) {
                    fbdInfoList.remove(this.remove_fbdindex);
                }
                if (vtInfoList.size() >= 10) {
                    ToastUtils.showToast(this.context, this.context.getString(R.string.vir_max_num));
                }
            }
        } else if (MapEditActivity901.isMopFbdEdit) {
            downUnifyFbd(fbdInfoList, 10, this.MOPFBD);
        } else if (MapEditActivity901.isOvaFbdEdit) {
            downUnifyFbd(fbdInfoList, 10, this.OVAFBD);
        } else if (MapEditActivity901.isPatEdit || MapEditActivity901.isPatNameEdit) {
            initDraging(event);
        } else if (MapEditActivity901.isWhgEdit) {
            downUnifyFbd(whgInfoList, 1, this.WHGFBD);
        }
    }

    private void downUnifyFbd(ArrayList<ForbiddenInfo> list, int maxSize, int type) {
        if (MapEditActivity901.isWhgEdit) {
            if (list.size() != 0) {
                this.oneContains = traverseFbdList(list, (int) this.start_x, (int) this.start_y);
                this.firstRemove = this.oneContains;
                if (this.oneContains && (this.mode == 11 || this.mode == 9)) {
                    whgInfoList.remove(this.remove_fbdindex);
                }
                if (list.size() >= maxSize && !this.oneContains) {
                    ToastUtils.showToast(this.context, this.context.getString(R.string.whg_max_num));
                    return;
                }
                return;
            }
            initfbdast(type);
        } else if (vtInfoList.size() == 0 && list.size() == 0) {
            initfbdast(type);
        } else {
            boolean vir = traverseVirList((int) this.start_x, (int) this.start_y);
            boolean fbd = traverseFbdList(list, (int) this.start_x, (int) this.start_y);
            this.oneContains = vir || fbd;
            this.firstRemove = this.oneContains;
            if (this.oneContains && (this.mode == 8 || this.mode == 6)) {
                vtInfoList.remove(this.remove_virindex);
            }
            if (this.oneContains && (this.mode == 11 || this.mode == 9)) {
                list.remove(this.remove_fbdindex);
            }
            if (list.size() >= maxSize && !fbd) {
                ToastUtils.showToast(this.context, this.context.getString(R.string.fbr_max_num));
            } else if (!fbd) {
                initfbdast(type);
            }
        }
    }

    private void initfbdast(int type) {
        this.fbdInfo = new ForbiddenInfo();
        this.fbdInfo.setFbdType(type);
    }

    private boolean traverseVirList(int drag_x, int drag_y) {
        for (int i = 0; i < vtInfoList.size(); i++) {
            Rect pulRect = vtInfoList.get(i).getPulRect();
            Rect delRect = vtInfoList.get(i).getDelRect();
            int[] ints = vtInfoList.get(i).getVirData();
            this.remove_virindex = i;
            if (pulRect.contains(drag_x, drag_y)) {
                this.mode = 7;
                this.adjvir_point = vtInfoList.get(i).getVirData();
                return true;
            } else if (delRect.contains(drag_x, drag_y)) {
                this.mode = 8;
                return true;
            } else if (DataUtils.getPointToLineDistence(ints[0], ints[1], ints[2], ints[3], drag_x, drag_y)) {
                this.mode = 6;
                this.drgvir_point = vtInfoList.get(i).getVirData();
                return true;
            }
        }
        return false;
    }

    private boolean traverseFbdList(ArrayList<ForbiddenInfo> list, int drag_x, int drag_y) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            int[] fbdData = list.get(i).getFbdData();
            this.mLeft.set(fbdData[0], fbdData[1]);
            this.mTop.set(fbdData[2], fbdData[3]);
            this.mRight.set(fbdData[4], fbdData[5]);
            this.mBottom.set(fbdData[6], fbdData[7]);
            Rect delRect = list.get(i).getDelRect();
            Rect pulRect = list.get(i).getPulRect();
            Rect rotRect = list.get(i).getRotRect();
            this.remove_fbdindex = i;
            this.fbdType = list.get(i).getFbdType();
            this.mn = DataUtils.getMaxMin(fbdData);
            this.jugPath = DataUtils.getPath(this.jugPath, fbdData);
            if (delRect.contains(drag_x, drag_y)) {
                this.mode = 11;
                return true;
            } else if (pulRect.contains(drag_x, drag_y)) {
                this.mode = 10;
                doAdjustFb(fbdData);
                return true;
            } else if (rotRect.contains(drag_x, drag_y)) {
                this.mode = 12;
                this.rotCenterP.set((float) ((fbdData[0] + fbdData[4]) / 2), (float) ((fbdData[1] + fbdData[5]) / 2));
                this.centerP.set((fbdData[0] + fbdData[4]) / 2, (fbdData[1] + fbdData[5]) / 2);
                this.preMoveP.set((float) drag_x, (float) drag_y);
                this.leftP.set(fbdData[0], fbdData[1]);
                this.topP.set(fbdData[2], fbdData[3]);
                this.rightP.set(fbdData[4], fbdData[5]);
                this.bottomP.set(fbdData[6], fbdData[7]);
                return true;
            } else if (compPathArea(drag_x, drag_y)) {
                this.mode = 9;
                this.fbdRect = delRect;
                this.fbpRect = pulRect;
                this.fbrRect = rotRect;
                return true;
            }
        }
        return false;
    }

    private boolean compPathArea(int dragx, int dragy) {
        this.fbdRegion.set(this.mn[1], this.mn[3], this.mn[0], this.mn[2]);
        this.fbdRegion.setPath(this.jugPath, this.fbdRegion);
        return this.fbdRegion.contains(dragx, dragy);
    }

    private void doAdjustFb(int[] adPath) {
        this.adLeft.set(adPath[0], adPath[1]);
        if (adPath[0] != adPath[2] || adPath[1] != adPath[7] || adPath[3] != adPath[5] || adPath[4] != adPath[6]) {
            this.adTop.set(adPath[2], adPath[3]);
            this.adK = (((double) (this.adTop.y - this.adLeft.y)) * 1.0d) / ((double) (this.adTop.x - this.adLeft.x));
            this.adKInc = ((double) this.adLeft.y) - (this.adK * ((double) this.adLeft.x));
            this.adJInc = ((double) this.adLeft.y) - ((-1.0d / this.adK) * ((double) this.adLeft.x));
        }
    }

    private void doVirtualActionMoveOperate(MotionEvent event) {
        this.matrix.getValues(this.values);
        PointF virMove = getMatrixValues(event, 2);
        this.move_x = virMove.x;
        this.move_y = virMove.y;
        this.trsx = (int) (this.move_x - this.start_x);
        this.trsy = (int) (this.move_y - this.start_y);
        doMoveOperate(event);
    }

    private void doMoveOperate(MotionEvent event) {
        if (MapEditActivity901.isVirEdit || MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit) {
            moveVirFbdOperete(vtInfoList, fbdInfoList, 10);
        } else if (MapEditActivity901.isPatEdit || MapEditActivity901.isPatNameEdit) {
            if (DataUtils.distance2Point(event.getX(), event.getY(), this.startPoint.x, this.startPoint.y) > 3.0f) {
                doDragOrZoom(event);
            }
        } else if (MapEditActivity901.isWhgEdit) {
            moveVirFbdOperete(vtInfoList, whgInfoList, 1);
        }
    }

    private void moveVirFbdOperete(ArrayList<VirTualInfo> vtInfoList2, ArrayList<ForbiddenInfo> fbdInfoList2, int maxsize) {
        if (this.oneContains && !this.twoContains) {
            MyLog.e(TAG, "moveeeeee:" + this.firstRemove + "," + this.remove_fbdindex);
            if (this.firstRemove) {
                if (this.mode == 7) {
                    vtInfoList2.remove(this.remove_virindex);
                    this.isRemoved = true;
                } else if (this.mode == 6 || this.mode == 8) {
                    this.isRemoved = true;
                }
                if (this.mode == 10 || this.mode == 12) {
                    fbdInfoList2.remove(this.remove_fbdindex);
                    this.isRemoved = true;
                } else if (this.mode == 9 || this.mode == 11) {
                    this.isRemoved = true;
                }
                if (this.isRemoved) {
                    this.firstRemove = false;
                }
            }
            if (this.mode == 6) {
                this.newVirP[0] = this.drgvir_point[0] + this.trsx;
                this.newVirP[1] = this.drgvir_point[1] + this.trsy;
                this.newVirP[2] = this.drgvir_point[2] + this.trsx;
                this.newVirP[3] = this.drgvir_point[3] + this.trsy;
                invalidate();
            } else if (this.mode == 7) {
                int sx = this.adjvir_point[0];
                int sy = this.adjvir_point[1];
                float x2 = Math.abs(((float) sx) - this.move_x);
                float y2 = Math.abs(((float) sy) - this.move_y);
                double dis2 = Math.sqrt((double) ((x2 * x2) + (y2 * y2)));
                if (dis2 < 20.0d) {
                    PointF pt = DataUtils.getRadiusPoint(sx, sy, (int) this.move_x, (int) this.move_y);
                    this.move_x = pt.x;
                    this.move_y = pt.y;
                    MyLog.e(TAG, "dfddfdfdf move:" + dis2 + "<->" + this.move_x + "<->" + this.move_y);
                }
                invalidate();
            } else if (this.mode == 8) {
                invalidate();
            } else if (this.mode == 9) {
                confirmDRect(this.mvdRect, this.fbdRect);
                confirmDRect(this.mvpRect, this.fbpRect);
                confirmDRect(this.mvrRect, this.fbrRect);
                invalidate();
            } else if (this.mode == 10) {
                int sx2 = this.adLeft.x;
                int sy2 = this.adLeft.y;
                float x3 = Math.abs(((float) sx2) - this.move_x);
                float y3 = Math.abs(((float) sy2) - this.move_y);
                if (Math.sqrt((double) ((x3 * x3) + (y3 * y3))) < 20.0d) {
                    PointF pt2 = DataUtils.getRadiusPoint(sx2, sy2, (int) this.move_x, (int) this.move_y);
                    this.move_x = pt2.x;
                    this.move_y = pt2.y;
                    if (this.adK != 0.0d) {
                        gettopbotPoint();
                    }
                } else if (this.adK != 0.0d) {
                    gettopbotPoint();
                }
                invalidate();
            } else if (this.mode == 12) {
                this.curMoveP.set(this.move_x, this.move_y);
                float rotAngle = DataUtils.getDegree(this.rotCenterP, this.preMoveP, this.curMoveP);
                this.rotLeft = SettingUtils.obtainRoationPoint(this.centerP, this.leftP, rotAngle);
                this.rotTop = SettingUtils.obtainRoationPoint(this.centerP, this.topP, rotAngle);
                this.rotRight = SettingUtils.obtainRoationPoint(this.centerP, this.rightP, rotAngle);
                this.rotBottom = SettingUtils.obtainRoationPoint(this.centerP, this.bottomP, rotAngle);
                invalidate();
            } else if (this.mode == 11) {
                invalidate();
            }
        } else if (!this.oneContains && !this.twoContains) {
            if (MapEditActivity901.isVirEdit) {
                if (vtInfoList2.size() >= maxsize) {
                    return;
                }
                if (Math.abs(this.trsx) > 20 || Math.abs(this.trsy) > 20) {
                    this.mode = 4;
                    invalidate();
                }
            } else if ((!MapEditActivity901.isMopFbdEdit && !MapEditActivity901.isOvaFbdEdit && !MapEditActivity901.isWhgEdit) || fbdInfoList2.size() >= maxsize) {
            } else {
                if (Math.abs(this.trsx) > 20 || Math.abs(this.trsy) > 20) {
                    this.mode = 5;
                    invalidate();
                }
            }
        }
    }

    private void gettopbotPoint() {
        double mpKInc = ((double) this.move_y) - (this.adK * ((double) this.move_x));
        double mpJInc = ((double) this.move_y) - ((-1.0d / this.adK) * ((double) this.move_x));
        this.mvtopx = (this.adKInc - mpJInc) / ((-1.0d / this.adK) - this.adK);
        this.mvtopy = ((-1.0d / this.adK) * this.mvtopx) + mpJInc;
        this.mvbtmx = (this.adJInc - mpKInc) / (this.adK - (-1.0d / this.adK));
        this.mvbtmy = (this.adK * this.mvbtmx) + mpKInc;
    }

    private void drawUnifyFbdPath(int start_x2, int start_y2, int sx, int my, int move_x2, int move_y2, int mx, int sy, int fbdtype) {
        this.fbdPath = DataUtils.getPath(this.fbdPath, new int[]{start_x2, start_y2, sx, my, move_x2, move_y2, mx, sy});
        float[] floats = {(float) start_x2, (float) start_y2, (float) sx, (float) my, (float) sx, (float) my, (float) move_x2, (float) move_y2, (float) move_x2, (float) move_y2, (float) mx, (float) sy, (float) mx, (float) sy, (float) start_x2, (float) start_y2};
        if (fbdtype == this.OVAFBD) {
            this.mCanvas.drawPath(this.fbdPath, this.paint_ovafbd);
            this.mCanvas.drawLines(floats, this.paint_stroke);
        } else if (fbdtype == this.MOPFBD) {
            this.mCanvas.drawPath(this.fbdPath, this.paint_mopfbd);
            this.mCanvas.drawLines(floats, this.paint_mopfbd);
        } else if (fbdtype == this.WHGFBD) {
            this.mCanvas.drawPath(this.fbdPath, this.paint_whgfbd);
            this.mCanvas.drawLines(floats, this.paint_whgfbd);
        }
    }

    private void confirmDRect(Rect newRect, Rect rgRect) {
        newRect.left = rgRect.left + this.trsx;
        newRect.top = rgRect.top + this.trsy;
        newRect.right = rgRect.right + this.trsx;
        newRect.bottom = rgRect.bottom + this.trsy;
    }

    private static Rect getDstRect(int x2, int y2) {
        return new Rect(x2 - (picW / 2), y2 - (picH / 2), (picW / 2) + x2, (picH / 2) + y2);
    }

    private static Rect getSaveRect(int x2, int y2) {
        return new Rect(x2 - (picW / 2), y2 - (picH / 2), (picW / 2) + x2, (picH / 2) + y2);
    }

    private Rect getDstRects(int x2, int y2) {
        return new Rect(x2 - (this.chgWidth / 2), y2 - (this.chgHeight / 2), (this.chgWidth / 2) + x2, (this.chgHeight / 2) + y2);
    }

    private void doVirtualActionUpOperate(MotionEvent event) {
        this.matrix.getValues(this.values);
        PointF virUp = getMatrixValues(event, 3);
        this.end_x = virUp.x;
        this.end_y = virUp.y;
        MyLog.e(TAG, "action up===:" + this.end_x + "," + this.end_y + "<-->" + event.getX() + "," + event.getY());
        doUpOperate((int) (this.end_x - this.start_x), (int) (this.end_y - this.start_y), this.end_x, this.end_y, event);
    }

    private void doUpOperate(int esdx, int esdy, float end_x2, float end_y2, MotionEvent event) {
        if (MapEditActivity901.isVirEdit || MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit) {
            upVirFbdOperate(fbdInfoList, 10, esdx, esdy, end_x2, end_y2);
        } else if (MapEditActivity901.isPatEdit || MapEditActivity901.isPatNameEdit) {
            if (DataUtils.distance2Point(event.getX(), event.getY(), this.startPoint.x, this.startPoint.y) < 3.0f) {
                if (MapEditActivity901.isPatEdit) {
                    changeMapRoomColorPat();
                } else if (MapEditActivity901.isPatNameEdit) {
                    changeMapRoomColorName();
                }
            }
        } else if (MapEditActivity901.isWhgEdit) {
            upVirFbdOperate(whgInfoList, 1, esdx, esdy, end_x2, end_y2);
        }
        invalidate();
    }

    private void changeMapRoomColorPat() {
        MyLog.e(TAG, "test crash on check room up:" + this.start_x + "," + this.start_y);
        if (this.start_x >= 0.0f && this.start_y >= 0.0f) {
            int pixel = this.bitmap_mapid.getPixel((int) this.start_x, (int) this.start_y);
            for (Map.Entry<Integer, Paint> entry : drawHm.entrySet()) {
                int key = entry.getKey().intValue();
                Paint drHmp = entry.getValue();
                if (pixel == drHmp.getColor()) {
                    Paint hmp = hm.get(Integer.valueOf(key));
                    Paint hmsp = hms.get(Integer.valueOf(key));
                    if (pixel == hmp.getColor()) {
                        drHmp.setColor(hmsp.getColor());
                        if (key != 1) {
                            rmidHm.put(Integer.valueOf(key + 10), true);
                        } else if (rmidHm.containsKey(2)) {
                            rmidHm.put(2, true);
                        } else if (rmidHm.containsKey(11)) {
                            rmidHm.put(11, true);
                        }
                    } else {
                        drHmp.setColor(hmp.getColor());
                        if (key != 1) {
                            rmidHm.put(Integer.valueOf(key + 10), false);
                        } else if (rmidHm.containsKey(2)) {
                            rmidHm.put(2, false);
                        } else if (rmidHm.containsKey(11)) {
                            rmidHm.put(11, false);
                        }
                    }
                }
            }
        }
    }

    private void changeMapRoomColorName() {
        MyLog.e(TAG, "test crash on name room up:" + this.start_x + "," + this.start_y);
        if (this.start_x >= 0.0f && this.start_y >= 0.0f) {
            int pixel = this.bitmap_mapid.getPixel((int) this.start_x, (int) this.start_y);
            this.keyP = new int[]{(int) this.end_x, (int) (1500.0f - this.end_y)};
            for (Map.Entry<Integer, Paint> entry : drawHm.entrySet()) {
                int key = entry.getKey().intValue();
                Paint drHmp = entry.getValue();
                if (pixel == drHmp.getColor()) {
                    drHmp.setColor(hms.get(Integer.valueOf(key)).getColor());
                    this.info.setIdkey(key + 10);
                    this.info.setPresscoordinate(this.keyP);
                    EventBus.getDefault().post(this.info);
                } else {
                    drHmp.setColor(hm.get(Integer.valueOf(key)).getColor());
                }
            }
        }
    }

    private void upVirFbdOperate(ArrayList<ForbiddenInfo> list, int maxsize, int esdx, int esdy, float end_x2, float end_y2) {
        if (!this.oneContains || this.twoContains) {
            if (!this.oneContains && !this.twoContains) {
                if (MapEditActivity901.isVirEdit) {
                    this.virPoint = new int[]{(int) this.start_x, (int) this.start_y, (int) end_x2, (int) end_y2};
                    if (vtInfoList.size() >= maxsize) {
                        return;
                    }
                    if (Math.abs(end_x2 - this.start_x) > 20.0f || Math.abs(end_y2 - this.start_y) > 20.0f) {
                        addVirtualToList(this.virPoint);
                    }
                } else if (MapEditActivity901.isMopFbdEdit || MapEditActivity901.isOvaFbdEdit || MapEditActivity901.isWhgEdit) {
                    this.fbdPoint = new int[]{(int) this.start_x, (int) this.start_y, (int) this.start_x, (int) end_y2, (int) end_x2, (int) end_y2, (int) end_x2, (int) this.start_y};
                    if (list.size() >= maxsize) {
                        return;
                    }
                    if (Math.abs(end_x2 - this.start_x) > 20.0f || Math.abs(end_y2 - this.start_y) > 20.0f) {
                        addForbiddenToList(list, this.fbdPoint);
                    }
                }
            }
        } else if (this.isRemoved || this.mode == 6 || this.mode == 9) {
            if (this.mode == 6) {
                int[] iArr = this.drgvir_point;
                iArr[0] = iArr[0] + esdx;
                int[] iArr2 = this.drgvir_point;
                iArr2[1] = iArr2[1] + esdy;
                int[] iArr3 = this.drgvir_point;
                iArr3[2] = iArr3[2] + esdx;
                int[] iArr4 = this.drgvir_point;
                iArr4[3] = iArr4[3] + esdy;
                virtualUniStep(this.drgvir_point);
            } else if (this.mode == 7) {
                float x2 = Math.abs(((float) this.adjvir_point[0]) - end_x2);
                float y2 = Math.abs(((float) this.adjvir_point[1]) - end_y2);
                if (((float) Math.sqrt((double) ((x2 * x2) + (y2 * y2)))) < 20.0f) {
                    this.adjvir_point[2] = (int) this.move_x;
                    this.adjvir_point[3] = (int) this.move_y;
                } else {
                    this.adjvir_point[2] = (int) end_x2;
                    this.adjvir_point[3] = (int) end_y2;
                }
                virtualUniStep(this.adjvir_point);
            } else if (this.mode == 8) {
                this.mode = 1;
            } else if (this.mode == 9) {
                ForbiddenInfo info2 = new ForbiddenInfo();
                int[] moveFB = {this.mLeft.x + esdx, this.mLeft.y + esdy, this.mTop.x + esdx, this.mTop.y + esdy, this.mRight.x + esdx, this.mRight.y + esdy, this.mBottom.x + esdx, this.mBottom.y + esdy};
                info2.setFbdData(moveFB);
                info2.setModifyed(true);
                info2.setNewAdd(true);
                info2.setFbdType(this.fbdType);
                rAddDRectToMap(this.fbdRect);
                rAddDRectToMap(this.fbpRect);
                rAddDRectToMap(this.fbrRect);
                info2.setDelRect(this.fbdRect);
                info2.setPulRect(this.fbpRect);
                info2.setRotRect(this.fbrRect);
                judgeForbiddenWithHostAndCharge(moveFB);
                list.add(info2);
                this.mode = 1;
            } else if (this.mode == 10) {
                int sx = this.adLeft.x;
                int sy = this.adLeft.y;
                float x3 = Math.abs(((float) sx) - end_x2);
                float y3 = Math.abs(((float) sy) - end_y2);
                double dis2 = Math.sqrt((double) ((x3 * x3) + (y3 * y3)));
                ForbiddenInfo info3 = new ForbiddenInfo();
                if (dis2 < 20.0d) {
                    if (this.adK == 0.0d) {
                        addFbdNoadk(info3, new int[]{this.adLeft.x, this.adLeft.y, this.adLeft.x, (int) this.move_y, (int) this.move_x, (int) this.move_y, (int) this.move_x, this.adLeft.y});
                    } else {
                        addFbdNoadk(info3, new int[]{this.adLeft.x, this.adLeft.y, (int) this.mvtopx, (int) this.mvtopy, (int) this.move_x, (int) this.move_y, (int) this.mvbtmx, (int) this.mvbtmy});
                        this.adK = 0.0d;
                    }
                } else if (this.adK == 0.0d) {
                    addFbdNoadk(info3, new int[]{this.adLeft.x, this.adLeft.y, this.adLeft.x, (int) end_y2, (int) end_x2, (int) end_y2, (int) end_x2, this.adLeft.y});
                } else {
                    addFbdNoadk(info3, new int[]{this.adLeft.x, this.adLeft.y, (int) this.mvtopx, (int) this.mvtopy, (int) end_x2, (int) end_y2, (int) this.mvbtmx, (int) this.mvbtmy});
                    this.adK = 0.0d;
                }
                list.add(info3);
                this.mode = 1;
            } else if (this.mode == 11) {
                this.mode = 1;
            } else if (this.mode == 12) {
                ForbiddenInfo info4 = new ForbiddenInfo();
                int[] rotFB = {this.rotLeft.x, this.rotLeft.y, this.rotTop.x, this.rotTop.y, this.rotRight.x, this.rotRight.y, this.rotBottom.x, this.rotBottom.y};
                info4.setFbdData(rotFB);
                info4.setNewAdd(true);
                info4.setModifyed(true);
                info4.setFbdType(this.fbdType);
                saveForbidenPicRect(rotFB, info4);
                judgeForbiddenWithHostAndCharge(rotFB);
                list.add(info4);
                this.mode = 1;
            }
            if (this.isRemoved) {
                this.isRemoved = false;
            }
        }
    }

    private void addFbdNoadk(ForbiddenInfo info2, int[] adFBAry) {
        info2.setFbdData(adFBAry);
        info2.setNewAdd(true);
        info2.setModifyed(true);
        info2.setFbdType(this.fbdType);
        saveForbidenPicRect(adFBAry, info2);
        judgeForbiddenWithHostAndCharge(adFBAry);
    }

    private void virtualUniStep(int[] arr) {
        judgeVirtualWithHostAndCharge(arr[0], arr[1], arr[2], arr[3]);
        VirTualInfo info2 = new VirTualInfo();
        info2.setModifyed(true);
        info2.setNewAdd(true);
        info2.setVirData(arr);
        saveRects(arr, info2);
        vtInfoList.add(info2);
        this.mode = 1;
    }

    public static void saveRects(int[] pointlist, VirTualInfo info2) {
        int sx = pointlist[0];
        int sy = pointlist[1];
        info2.setPulRect(getSaveRect(pointlist[2], pointlist[3]));
        info2.setDelRect(getSaveRect(sx, sy));
    }

    private void addVirtualToList(int[] realPoint) {
        judgeVirtualWithHostAndCharge(realPoint[0], realPoint[1], realPoint[2], realPoint[3]);
        VirTualInfo info2 = new VirTualInfo();
        info2.setModifyed(true);
        info2.setNewAdd(true);
        info2.setVirData(realPoint);
        saveRects(realPoint, info2);
        vtInfoList.add(info2);
    }

    private void addForbiddenToList(ArrayList<ForbiddenInfo> list, int[] fbPoint) {
        judgeForbiddenWithHostAndCharge(fbPoint);
        this.fbdInfo.setFbdData(fbPoint);
        this.fbdInfo.setModifyed(true);
        this.fbdInfo.setNewAdd(true);
        saveForbidenPicRect(fbPoint, this.fbdInfo);
        list.add(this.fbdInfo);
    }

    private void rAddDRectToMap(Rect rect) {
        rect.left += (int) (this.end_x - this.start_x);
        rect.top += (int) (this.end_y - this.start_y);
        rect.right += (int) (this.end_x - this.start_x);
        rect.bottom += (int) (this.end_y - this.start_y);
    }

    public static void saveForbidenPicRect(int[] fbPoint, ForbiddenInfo info2) {
        info2.setDelRect(getSaveRect(fbPoint[0], fbPoint[1]));
        info2.setPulRect(getSaveRect(fbPoint[4], fbPoint[5]));
        info2.setRotRect(getSaveRect(fbPoint[6], fbPoint[7]));
    }

    public void judgeVirtualWithHostAndCharge(int sx, int sy, int ex, int ey) {
        int type = DataUtils.judgeVirAndHostCharge(sx, sy, ex, ey, this.mhostP, this.mchargeP);
        if (type == 1) {
            ToastUtils.showToast(this.context, this.context.getString(R.string.host_in_virtual));
        } else if (type == 2) {
            ToastUtils.showToast(this.context, this.context.getString(R.string.charge_in_virtual));
        }
    }

    private void judgeForbiddenWithHostAndCharge(int[] fbdAry) {
        if (!MapEditActivity901.isWhgEdit) {
            int type = DataUtils.judgeFbdAndHostCharge(fbdAry, this.mhostP, this.mchargeP, this.hostPH, this.chargePH);
            if (type == 1) {
                ToastUtils.showToast(this.context, this.context.getString(R.string.host_in_forbidden));
            } else if (type == 2) {
                ToastUtils.showToast(this.context, this.context.getString(2131296964));
            } else if (type == 3) {
                ToastUtils.showToast(this.context, this.context.getString(R.string.host_close_forbidden));
            } else if (type == 4) {
                ToastUtils.showToast(this.context, this.context.getString(R.string.charge_close_forbidden));
            }
        }
    }

    private void initDraging(MotionEvent event) {
        this.startPoint.set(event.getX(), event.getY());
        this.mode = 2;
    }

    private void initZooming(MotionEvent event) {
        this.oriDis = DataUtils.distance(event);
        if (this.oriDis > 10.0f) {
            this.midPoint = DataUtils.midPoint(event);
            this.mode = 3;
        }
    }

    private void doDragOrZoom(MotionEvent event) {
        if (this.mode == 2) {
            this.drgx = ((event.getX() - this.startPoint.x) / this.curScale) + this.dx;
            this.drgy = ((event.getY() - this.startPoint.y) / this.curScale) + this.dy;
            MyLog.e(TAG, "Draging===:" + this.drgx + "," + this.drgy + "<->" + this.dx + "," + this.dy);
            invalidate();
        } else if (this.mode == 3) {
            MyLog.e(TAG, "Zooming===:<->" + this.curScale);
            float newDist = DataUtils.distance(event);
            if (newDist > 10.0f) {
                this.curScale = (newDist / this.oriDis) * this.orgScale;
                if (this.curScale >= this.maxScale) {
                    this.curScale = this.maxScale;
                }
                if (this.curScale <= this.minScale) {
                    this.curScale = this.minScale;
                }
                invalidate();
            }
        }
    }

    private PointF getMatrixValues(MotionEvent event, int type) {
        float x2 = (event.getX() - this.values[2]) / this.values[0];
        float y2 = (event.getY() - this.values[5]) / this.values[0];
        MyLog.e(TAG, "test crash on getMatrixValues:" + type + "," + event.getX() + "," + event.getY() + "<->" + this.values[2] + "," + this.values[0] + "," + this.values[5] + "<->" + x2 + "," + y2);
        return new PointF(x2, y2);
    }

    private void drawVirSmallPic(int dx2, int dy2, int px, int py) {
        this.mCanvas.drawBitmap(this.del_bitmap, this.srcRect, getDstRect(dx2, dy2), (Paint) null);
        this.mCanvas.drawBitmap(this.pul_bitmap, this.srcRect, getDstRect(px, py), (Paint) null);
    }

    private void drawFbdSmallPic(int dx2, int dy2, int px, int py, int rx, int ry) {
        this.mCanvas.drawBitmap(this.del_bitmap, this.srcRect, getDstRect(dx2, dy2), (Paint) null);
        this.mCanvas.drawBitmap(this.pul_bitmap, this.srcRect, getDstRect(px, py), (Paint) null);
        this.mCanvas.drawBitmap(this.rot_bitmap, this.srcRect, getDstRect(rx, ry), (Paint) null);
    }

    public void resetPatitionMapData() {
        drawHm.clear();
        drawHm = DisplayUtil.getdrPainthm(this.context);
        for (Map.Entry<Integer, Boolean> entry : rmidHm.entrySet()) {
            rmidHm.put(Integer.valueOf(entry.getKey().intValue()), false);
        }
        invalidate();
    }

    public boolean isExistCheckRoom() {
        for (Map.Entry<Integer, Boolean> entry : rmidHm.entrySet()) {
            if (entry.getValue().booleanValue()) {
                return true;
            }
        }
        return false;
    }

    public void setEditData(byte[] hsbyte, byte[] slambyte, PointF centerP2, Point chargP, Point hostP, int xmax, int xmin, int ymax, int ymin) {
        this.mapidBytes = null;
        this.slamBytes = null;
        this.mapidBytes = hsbyte;
        this.slamBytes = slambyte;
        this.mcenterP = centerP2;
        this.mchargeP = chargP;
        this.mhostP = hostP;
        this.hostPH.reset();
        this.hostPH.addCircle((float) this.mhostP.x, (float) this.mhostP.y, 10.0f, Path.Direction.CW);
        this.chargePH.reset();
        this.chargePH.addCircle((float) this.mchargeP.x, (float) this.mchargeP.y, 10.0f, Path.Direction.CW);
        int xdistence = xmax - xmin;
        int ydistence = ymax - ymin;
        if (!(xdistence == 0 || ydistence == 0)) {
            this.curScale = (float) ((((double) this.width) * 1.0d) / ((double) (xdistence > ydistence ? xdistence : ydistence)));
        }
        if (this.curScale >= 5.0f) {
            this.curScale = 5.0f;
        }
        if (this.curScale <= 0.5f) {
            this.curScale = 0.5f;
        }
        this.orgScale = this.curScale;
    }

    public static void setRoomName(HashMap<Integer, RoomNameInfo> nmlist) {
        nameList = nmlist;
    }
}
